<%@ tag pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/jsp/common/global.jsp" %>

<%@ attribute name="id" required="true" type="java.lang.String" %>
<%@ attribute name="pager" required="true" type="org.smart4j.framework.dao.bean.Pager" %>

<c:set var="pageNumber" value="${pager.pageNumber}"/>
<c:set var="pageSize" value="${pager.pageSize}"/>
<c:set var="totalRecord" value="${pager.totalRecord}"/>
<c:set var="totalPage" value="${pager.totalPage}"/>

<div  id="${id}" class="pagination">
    <span class="label label-info"><f:message key="common.pager.page_number"/>:</span>
    <input type="text" value="${pageNumber}" class="input-mini ext-pager-pn">
    <span>/</span>
    <span class="ext-pager-tp badge badge-primary">${totalPage}</span>
    <span class="label label-info"><f:message key="common.pager.page_size"/>:</span>
    <input type="text" value="${pageSize}" class="input-mini ext-pager-ps">
    <span class="label label-info"><f:message key="common.pager.total_record"/>:</span>
    <span class="badge badge-primary">${totalRecord}</span>

    <ul class="ext-pager-button">
        <c:choose>
            <c:when test="${pageNumber > 1 && pageNumber <= totalPage}">
                <li><button class="btn btn-default" type="button" title="<f:message key="common.pager.first"/>" data-pn="1">|&lt;</button></li>
                <li><button class="btn btn-default" type="button" title="<f:message key="common.pager.pre"/>" data-pn="${pageNumber - 1}">&lt;</button></li>
            </c:when>
            <c:otherwise>
                <li><button class="btn btn-default" type="button" title="<f:message key="common.pager.first"/>" disabled>|&lt;</button></li>
                <li><button class="btn btn-default"  type="button" title="<f:message key="common.pager.pre"/>" disabled>&lt;</button></li>
            </c:otherwise>
        </c:choose>
        <c:choose>
            <c:when test="${pageNumber < totalPage}">
                <li><button class="btn btn-default" type="button" title="<f:message key="common.pager.next"/>" data-pn="${pageNumber + 1}">&gt;</button></li>
                <li><button class="btn btn-default" type="button" title="<f:message key="common.pager.last"/>" data-pn="${totalPage}">&gt;|</button></li>
            </c:when>
            <c:otherwise>
                 <li><button class="btn btn-default" type="button" title="<f:message key="common.pager.next"/>" disabled>&gt;</button></li>
                 <li><button class="btn btn-default" type="button" title="<f:message key="common.pager.last"/>" disabled>&gt;|</button></li>
            </c:otherwise>
        </c:choose>
    </ul>
</div>
